<template>
    <div class="flex gap-2">
        <span class="zhifubao">
            <img src="@/assets/images/zhifubao.svg" width="24px">
            支付宝支付</span>
        <span class="wechat" @click="dialogVisible = true">
            <img src="@/assets/images/wechat.svg" width="24px">
            微信支付</span>
    </div>
    <el-dialog v-model="dialogVisible" title="扫码完成支付" width="500" :before-close="handleClose">
        <span>This is a message</span>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="dialogVisible = false">取消支付</el-button>
                <el-button type="primary" @click="dialogVisible = false">
                    支付完成
                </el-button>
            </div>
        </template>
    </el-dialog>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { ElMessageBox } from 'element-plus'

const dialogVisible = ref(false)

const handleClose = (done: () => void) => {
    ElMessageBox.confirm('Are you sure to close this dialog?')
        .then(() => {
            done()
        })
        .catch(() => {
            // catch error
        })
}
</script>

<style lang="scss" scoped >
.zhifubao {
    @apply bg-[#1677FF] text-white hover:bg-blue-400 cursor-pointer transition-all mt-8 w-full py-3 px-6 border border-transparent rounded-md text-center font-medium flex items-center justify-center gap-1;
}

.wechat {
    @apply bg-emerald-500 text-white hover:bg-emerald-600 cursor-pointer transition-all mt-8 w-full py-3 px-6 border border-transparent rounded-md text-center font-medium flex items-center justify-center gap-1;
}
</style>